//
//  UIImage+msg.m
//  runtime
//
//  Created by zxy on 2018/4/17.
//  Copyright © 2018年 zssh. All rights reserved.
//

#import "UIImage+msg.h"
#import <objc/runtime.h>
@implementation UIImage (msg)
// 既能加载图片又能打印
+(instancetype)imageWithName:(NSString *)name{
    UIImage *image = [self imageWithName:name];
    if(image == nil){
        NSLog(@"加载空的图片");
    }
    return image;
}

//加载分类到内存的时候调用
+(void)load{
    Method m1 = class_getClassMethod([UIImage class], @selector(imageWithName:));
    Method m2 = class_getClassMethod([UIImage class], @selector(imageNamed:));
    method_exchangeImplementations(m1, m2);
}
@end
